from typing import Optional, List, Dict

from sqlalchemy import Column, Integer, String, Text, Date
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.mutable import MutableDict
from sqlmodel import SQLModel, Field
from datetime import date

class SchoolInfo(SQLModel, table=True):
    __tablename__ = "school_info"

    id: Optional[int] = Field(default=None, primary_key=True)
    school: str
    prov_id: int
    city_id: int
    logo_url: str
    is_985: int
    is_211: int
    is_dfc: int
    is_art: int
    is_auto: int
    is_imp_prov: int
    is_imp_country: int
    is_gov: str
    batch: str
    prov: str
    city: str
    create_year: int
    attach: str
    tel: str
    num_stu_intl: int
    num_stu_undergraduate: int
    num_stu_graduate: int
    num_scholarship: int
    num_stu: str
    num_imp_pro: int
    num_doctor: int
    num_master: int
    ratio_male: int
    ratio_female: int
    official_web: str
    school_id: int
    intro_school: str
    history_culture: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
    dominant_pro: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
    famous_alumni: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
    teacher_strength: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
    scientific_institution: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
    salary_info: str
    prov_short: str
    city_short: str
    rank_all: str
    school_type: str
    img_urls: List[str]
    rank: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
    is_compare: int
    is_fav: int
    num_acade: int


class SchoolBrochure(SQLModel, table=True):
    __tablename__ = "school_brochure"

    id: Optional[int] = Field(default=None, primary_key=True)
    school: int
    title: str
    content: str
    create_date: date

class SchoolPlan(SQLModel, table=True):
    __tablename__ = "school_plan"

    id: Optional[int] = Field(default=None, primary_key=True)
    school_code: str
    school_name: str
    nature: str
    batch: str
    pro: str
    pro_code: str
    pro_note: str
    plan_num: int
    edu_system: str
    tuition: int

class SchoolScore(SQLModel, table=True):
    __tablename__ = "school_score"

    id: Optional[int] = Field(primary_key=True)
    data: MutableDict = Field(default={}, sa_column=Column(JSONB, nullable=True))
